import { reqCategoryList,reqGetBannerList,reqGetfloorList } from "@/api";
import { result } from "lodash";

const state = {
  // home中存储的三级菜单数据
  categroyList: [],
  // home中轮播图的数据
  bannerList: [],
  // floor数据
  floorList:[]
};
// 修改数据
const mutations = {
  CATEGORYLIST(state, categroyList) {
    state.categroyList = categroyList;
  },
  BANNERLIST(state, bannerList) {
    state.bannerList = bannerList;
  },
  FLOORLIST(state,floorList){
    state.floorList = floorList;
  }
};
// 业务逻辑
const actions = {
  // 通过api接口调用向服务器发送请求
  async categroyList({ commit }) {
    let result = await reqCategoryList();
    if (result.code == 200) {
      commit("CATEGORYLIST", result.data);
    }
  },
  // 获取首页轮播图
  async GetBannerList({commit}) {
    let result = await reqGetBannerList();
    if (result.code == 200) {
      commit("BANNERLIST", result.data);
    }
  },
  // 获取floor数据
  async GetfloorList({commit}){
    let result = await reqGetfloorList();
    if(result.code == 200){
      commit("FLOORLIST",result.data);
    }
  }
};
// 计算属性
const getters = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
